<template>
<div>
  <h1>添加角色配置</h1>
  {{id}}
  <select name="" id="" v-model="id">
    <option :value="i.id" v-for="i in rlist">{{i.name}}</option>
  </select>
  <van-checkbox-group v-model="ids">
    <van-checkbox :name="i.id" v-for='i in relist'>{{i.name}}</van-checkbox>
  </van-checkbox-group>
  <van-button @click='add'>添加</van-button>

</div>
</template>

<script>
export default {
  name: "roles_resources",
  data(){
    return{
      rlist : [],
      relist:[],
      ids:[],
      id:0

    }
  },
  methods:{
    get_roles(){
      this.$axios.get('admin/adminUser')
        .then(i=>{
          this.rlist = i.data.list
          this.get_resource()
        })
    },
    get_resource(){
      this.$axios.get('admin/resource')
      .then(i=>{
        this.relist = i.data.list
      })
    },
    add(){
      this.$axios.post('admin/resource',{id:this.id,ids:this.ids})
      .then(i=>{
      })
    },
  },
  mounted() {
    this.get_roles()

  }
}
</script>

<style scoped>

</style>
